package com.course.oauth2.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @PROJECT_NAME: course
 * @DESCRIPTION: 客户端配置类-将配置文件中的数据加载至类中
 * @Author: 涂玄武
 * @DATE: 2021/6/21 13:39
 */
@Component
@ConfigurationProperties(prefix = "client.oauth2")
public class ClientOAuth2DataConfiguration {

    /**
     * 客户端标识ID
     */
    private String clientId;

    /**
     * 客户端安全码
     */
    private String secret;

    /**
     * 授权类型
     */
    private String[] grantTypes;

    /**
     * token有效期
     */
    private int tokenValidityTime;

    /**
     * refresh-token有效期
     */
    private int refreshTokenValidtyTime;

    /**
     * 客户端访问范围
     */
    private String[] scopes;

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String[] getGrantTypes() {
        return grantTypes;
    }

    public void setGrantTypes(String[] grantTypes) {
        this.grantTypes = grantTypes;
    }

    public int getTokenValidityTime() {
        return tokenValidityTime;
    }

    public void setTokenValidityTime(int tokenValidityTime) {
        this.tokenValidityTime = tokenValidityTime;
    }

    public int getRefreshTokenValidtyTime() {
        return refreshTokenValidtyTime;
    }

    public void setRefreshTokenValidtyTime(int refreshTokenValidtyTime) {
        this.refreshTokenValidtyTime = refreshTokenValidtyTime;
    }

    public String[] getScopes() {
        return scopes;
    }

    public void setScopes(String[] scopes) {
        this.scopes = scopes;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("ClientOAuth2DataConfiguration{");
        sb.append("clientId='").append(clientId).append('\'');
        sb.append(", secret='").append(secret).append('\'');
        sb.append(", grantTypes=").append(grantTypes == null ? "null" : Arrays.asList(grantTypes).toString());
        sb.append(", tokenValidityTime=").append(tokenValidityTime);
        sb.append(", refreshTokenValidtyTime=").append(refreshTokenValidtyTime);
        sb.append(", scopes=").append(scopes == null ? "null" : Arrays.asList(scopes).toString());
        sb.append('}');
        return sb.toString();
    }
}
